function! g:Auto_Highlight_Cword()
	let cs = expand('<cword>')
	let csl = cs[len(cs) - 1]
	if csl == ',' || csl == ':' || csl == ';' || csl == '"' || csl == "'" || csl == '(' || csl == ')'
		let @/=''
	else
		"echo 'csl = @' . csl . '@'
		exe "let @/='\\<".expand("<cword>")."\\>'"
	endif
endfunction

function! g:Auto_Highlight_Toggle()
  if exists("#CursorHold#*")
    au! CursorHold *
    let @/=''
  else
    set hlsearch
	set updatetime=500
    au! CursorHold * nested call g:Auto_Highlight_Cword()
	let &ro = &ro
  endif
endfunction

if !exists('g:Auto_Highlight_Cursor_Word')
	let g:Auto_Highlight_Cursor_Word = 0
endif

function! g:Auto_Highlight_Init()
	if g:Auto_Highlight_Cursor_Word == 1
		call g:Auto_Highlight_Toggle()
	endif
endfunction

nnoremap <silent> <leader>hl :call g:Auto_Highlight_Toggle()<cr>

au! vimenter * call g:Auto_Highlight_Init()


